home *** CD-ROM | disk | FTP | other *** search
/ Aminet 5 / Aminet 5 - March 1995.iso / Aminet / dev / basic / RIBlitzLibs.lha / riblitzlibs / examples / ZoneTest.asc < prev    next >
Encoding:
Text File  |  1995-01-28  |  1.4 KB  |  59 lines

  1. ;########################
  2. ;# Example 1.2 ZoneTest #
  3. ;########################
  4. ; By Steven Matty
  5. ;
  6. ; This sets up 12 zones with either cicles or boxes around them
  7. ; If the dot comes into contact with one, the screen will flash
  8. ; Turn the lights down for a nice strobe :)
  9.  
  10. Screen 0,0,0,320,DispHeight,4,0,"Test program",1,2
  11. ScreensBitMap 0,0
  12. BitMapOutput 0
  13. Use BitMap 0
  14. For h=0 To 12
  15.   PalRGB 0,h,h+3,h+3,h+3
  16. Next h
  17. Use Palette 0                                   ; Use the palette
  18.  
  19. ZoneInit 0,12                                   ; Clear Zones 0-12
  20. ad.l=ZoneTable+4
  21. For n=12 To 0 Step -1
  22.   g=Int(Rnd(2))                                   ; Circle or Box
  23.   If g=0
  24.     x=Int(Rnd(320))
  25.     x2=Int(Rnd(320))
  26.     y=Int(Rnd(DispHeight-12))+12
  27.     y2=Int(Rnd(DispHeight-12))+12
  28.  
  29.     If x>x2 Then Exchange x,x2
  30.     If y>y2 Then Exchange y,y2
  31.  
  32.     Boxf x,y,x2,y2,n+3
  33.     SetZone n,x,y,x2,y2                       ; Set Box zone
  34.   Else
  35.     x=Int(Rnd(320-64))
  36.     y=Int(Rnd(DispHeight-64))
  37.  
  38.     Circlef x,y,32,n+3
  39.     SetZone n,x,y,32                              ; Set Circular zone
  40.   End If
  41. Next n
  42.  
  43. SetZoneMode 0
  44.  
  45. Repeat
  46.   xm.w=SMouseX
  47.   ym.w=SMouseY
  48.  
  49.   zn.w=Zone(xm,ym)                                ; Are we in the ZONE?
  50.   If zn<>-1
  51.     Locate 0,1
  52.     Print "Zone ",zn,",",GetZoneX1(zn)," ",GetZoneX2(zn)," ",GetZoneY1(zn)," ",GetZoneY2(zn),"      "
  53.   EndIf
  54.   VWait
  55. Until Joyb(0)                                  ; Until mousebutton
  56. AMIGA
  57. End
  58.  
  59.